package com.ymatou.iapi.userregister.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*直播微店买手注册Call
*FreeMaker Template自动生成代码
*/
public class SellerRegisterCall extends YmatouBaseCall{
	private static String opurl ="liveshop/sellerRegister";
	
	public SellerRegisterCall() {
		super(EnvSetup.getSystemUrl("userregister_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	/**
	 * 获取ResponseCode
	 * 
	 * @return
	 */
	public int getCode() {
		int ResponseCode = 0;
		try {
			ResponseCode = new JSONObject(getReturnData()).getInt("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseCode;
	}

	/**
	 * 获取data
	 * 
	 * @return
	 */
	public JSONObject getResult() {
		JSONObject Result = null;
		try {
			Result = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Result;
	}

	/**
	 * 获取userid
	 * 
	 * @return
	 */
	public int getUserid() {
		int Userid = 0;
		try {
			Userid = getResult().getInt("userId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Userid;
	}

	/**
	 * 获取userid
	 * 
	 * @return
	 */
	public String getAccessToken() {
		String Userid = null;
		try {
			Userid = getResult().getString("token");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Userid;
	}
}